package com.jsjosem.aftersales.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.jsjosem.aftersales.R;
import com.jsjosem.aftersales.data.response.ServicesResponse;

import java.util.List;

public class ServiceItemsAdapter extends ArrayAdapter<ServicesResponse> {
    public ServiceItemsAdapter(@NonNull Context context, int resource, @NonNull List<ServicesResponse> objects) {
        super(context, resource, objects);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        ServicesResponse item = getItem(position);
        @SuppressLint("ViewHolder") View view = LayoutInflater.from(getContext()).inflate(R.layout.service_item_list, parent, false);
        TextView serviceName = view.findViewById(R.id.service_name);
        TextView serviceCount = view.findViewById(R.id.service_count);
        TextView serviceUnit = view.findViewById(R.id.service_unit);
        TextView servicePrice = view.findViewById(R.id.service_cost);
        serviceName.setText(item.getName());
        serviceCount.setText(item.getCount().toString());
        serviceUnit.setText(item.getUnit());
        servicePrice.setText(item.getFeeFormat().toString());
        return view;
    }
}
